import { createSlice } from "@reduxjs/toolkit";
//RTK的切片数据，用与保存多个state数据并给各个组件使用
const watchstateSlice = createSlice({
    name: 'watchstate',
    //初始state值
    initialState: () => {
        // //先从磁盘里读取role
        // const localrole=localStorage.getItem('dmrole');

        return [];

    },
    reducers: {
        //修改state方法
        addwatchState(state, action) {
            // state = [...state, action.payload];
            state.push(action.payload);

        },
        removewatchState(state, action) {
            return state.filter(item=>item !== action.payload)
        }
    }

});
export default watchstateSlice;
export const { addwatchState, removewatchState } = watchstateSlice.actions;

